// 首页 公告
<template>
  <div class="w1920">
    <div class="homeNotice">
      <div class="title">
        <img src="@/assets/icon/notice.png" class="animated zoomInLeft">
        <b>网站公告:</b>
      </div>
      <!-- swiper -->
      <swiper :options="swiperOption" v-if=" announcement.length > 0 ">
        <swiper-slide v-for="(item,index) in announcement" :key="index">
          <div style="cursor: pointer;color:#333" :data-id="item.id" :data-pid="item.pid" :data-title="item.title">
            {{ item.title }}
            {{ item.description }}
          </div>
        </swiper-slide>
      </swiper>

      <div class="tianchong"></div>
    </div>
  </div>
</template>
<script>
  export default {
    name: "homeNotice",
    data() {
      return {
        announcement: this.$store.state.homeDisplay.announcement, // 公告
        swiperOption: {
          observer: true,
          observeParents: true,
          direction: "vertical",
          slidesPerView: 1,
          spaceBetween: 30,
          // mousewheel: true,    // 倒置出现一个很大的叹号 警告
          loop: true,
          autoplay: true,
          _this: this,
          //用on事件监听点击事件 用箭头函数解决this的指针的指向问题  修复点击事件失效的问题 点击问题失效和loop: true,有关系 暂时不知道什么关系以后有时间去探究下原因 暂时解决办法 用on 监听click的事件
          on: {
            click: (e) => {
              console.log(e.target.dataset)
              let item = {}
              item.id = e.target.dataset.id
              item.pid = e.target.dataset.pid
              item.title = e.target.dataset.title
              console.log(item)
              this.$store.commit('newleftgoto',item)
              this.$store.commit('newDetails',item)
              this.$router.push({
                name: "ConsultingDetails"
              })
            }
          }

        }
      }
    }
  }
</script>
<style lang="scss" scoped>
  .w1920 {
    // background-color: #f1f1f1;
    background-color: #fff;
    padding-top: 10px;
    padding-bottom: 10px;

    .homeNotice {
      width: 1200px;
      height: 30px;
      margin: auto;
      overflow: hidden;
      line-height: 30px;
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      // background: linear-gradient(to top right, rgb(106, 108, 109) 0%, rgba(255, 255, 255, 0.397) 50%, rgb(106, 108, 109) 100%);
      .title {
        width: 96px;
        display: flex;
        flex-direction: row;
        align-items: center;
        margin-left: 10px;
        color: #333;
        img {
          width: 18px;
          height: 18px;
          padding-right: 8px;
          animation-duration: 1.5s;
          animation-delay: 0s;
          animation-iteration-count: infinite;
        }
      }

      /deep/ .swiper-container {
        width: 1000px;

        .swiper-slide {
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
      }

      .tianchong {
        width: 100px;
      }
    }
  }
</style>
